cmake_minimum_required(VERSION 2.6)
project(libcore)

set (libcore_VERSION_MAJOR 0)
set (libcore_VERSION_MINOR 1)

cmake_policy(SET CMP0015 OLD)
include_directories( /usr/include/libxml2 include )

option(ENABLE_LIBXML "Use libxml" ON)
option(ENABLE_SSL "Use openssl" ON)

add_library(crcore STATIC
files.c exception.c crcore.c thread.c crutils.c hash_string_to_pointer.c stringbuffer.c stream.c streamio.c
hashtable.c error_messages.c xmlutils.c)

include(GNUInstallDirs)

message("Archive Dir:" ${CMAKE_INSTALL_FULL_LIBDIR} "Include:" ${CMAKE_INSTALL_FULL_INCLUDEDIR})
install(TARGETS crcore DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})

install(FILES
include/config.h
include/core_thread.h
include/crcore.h
include/crtypes.h
include/error_messages.h
include/exception.h
include/hash_string_to_pointer.h
include/hashtable.h
include/list.h
include/stream.h
include/stringbuffer.h
include/xmlutils.h
DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/crcore)

install(DIRECTORY
docs
DESTINATION ${CMAKE_INTALL_FULL_DOCSDIR}/kuato)

if(ENABLE_LIBXML)
	message( "LIBXML is Enabled" )
	add_definitions(-DENABLE_LIBXML)
endif(ENABLE_LIBXML)

if(ENABLE_SSL)
	message( "SSL is Enabled" )
	add_definitions(-DENABLE_SSL)
endif(ENABLE_SSL)

add_definitions( -Wall )

# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(docs ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.config
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)